﻿using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;

namespace Emilie.Converters
{
    public class NullVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {

            if (null == value ||
                (value is DateTime && ((DateTime)value).Equals(default(DateTime))) ||
                (value is TimeSpan && ((TimeSpan)value).Equals(default(TimeSpan))) ||
                (value is string && (string.IsNullOrWhiteSpace(value.ToString()))))
            {
                if (parameter == null)
                    return Visibility.Collapsed;
                else
                    return Visibility.Visible;
            }

            if (parameter != null)
                return Visibility.Collapsed;
            else
                return Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
